﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using IndoReputation.Models.BusinessObject;
using IndoReputation.Models.BusinessObject.Collections;
using IndoReputation.Models.DataAccess;

namespace IndoReputation.Models.BusinessLogic
{
    public class ReporterBOL
    {
        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 4/22/2012  6:03 PM
        /// Todo: Insert an reporter to db
        /// </summary>
        /// <param name="reporter">The reporter.</param>
        /// <returns></returns>
        public static int Insert(Reporter reporter)
        {
            try
            {
                reporter.CreateAt = DateTime.Now;
                reporter.CreateBy = MySession.UserID;
                reporter.UpdateAt = null;
                reporter.UpdateBy = null;
                return ReporterDAL.Insert(reporter);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  9:45 AM
        /// Todo: Update a User Exists in Database 
        /// </summary>
        /// <param name="reporter">A reporter.</param>
        /// <returns></returns>
        public static bool Update(Reporter reporter)
        {
            try
            {
                reporter.UpdateAt = DateTime.Now;
                reporter.UpdateBy = MySession.UserID;
                return ReporterDAL.Update(reporter);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  10:36 AM
        /// Todo: Delete a User Existst in Database
        /// </summary>
        /// <param name="reporter">A reporter.</param>
        /// <returns></returns>
        public static bool Delete(int reporterID)
        {
            try
            {
                return ReporterDAL.Delete(reporterID);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/29/2011  5:23 PM
        /// Todo: Get All Reporter
        /// </summary>
        /// <returns></returns>
        public static ReporterList GetAllReporter()
        {
            try
            {
                return ReporterDAL.GetAllReporter() ?? new ReporterList();
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  10:40 AM
        /// Todo: Select a User existst in Database
        /// </summary>
        /// <param name="reporterID">The reporter ID.</param>
        /// <returns></returns>
        public static Reporter GetReporterById(int reporterID)
        {
            try
            {
                return ReporterDAL.GetReporterById(reporterID);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  10:40 AM
        /// Todo: Select a User existst in Database
        /// </summary>
        /// <param name="reporterID">The reporter ID.</param>
        /// <returns></returns>
        public static List<Reporter> GetAllReporterByMediaID(int mediaID)
        {
            try
            {
                return ReporterDAL.GetAllReporterByMediaID(mediaID) ?? new List<Reporter>();
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
    }
}